<?php

/*
 * Base_Model
 * 全局通用方法
 */

class Base_Model extends CI_Model {

    //重载CI_Model
    public function __construct() {
        parent::__construct();
        $this->load->database();
    }

    /*
     * getID
     * 获取ID
     */

    public function GetID($idname, $table) {
        $this->db->select_max($idname);
        $query = $this->db->get($table);
        $result_array = $query->result_array();
        if ($result_array[0][$idname] == "") {
            return 10001;
        } else {
            return intval($result_array[0][$idname]) + 1;
        }
    }

    //创建日志
    public function log($log_name, $content) {
        $data = array(
            'u_id' => $this->session->userdata('uid'),
            'u_userName' => $this->session->userdata('uName'),
            "log_name" => $log_name,
            'log_content' => $content,
            "log_time" => time()
        );
        $this->db->insert('db_log', $data);
    }

    //创建日志
    public function logs($log_name, $content, $array) {
        $val = "";
        foreach ($content as $value) {
            $val.=$value . ",";
        }
        $val.="套系内容：";
        foreach ($array as $value) {
            $val.=$value . ",";
        }
        $data = array(
            'u_id' => $this->session->userdata('uid'),
            'u_userName' => $this->session->userdata('uName'),
            "log_name" => $log_name,
            'log_content' => $val,
            "log_time" => time()
        );
        $this->db->insert('db_log', $data);
    }

}

?>
